from rest_framework.mixins import ListModelMixin
from rest_framework.viewsets import GenericViewSet
from rest_framework import serializers
from apps.minapp.models import S_Notice


class NoticeSListSerializer(serializers.ModelSerializer):
    id = serializers.CharField()
    title = serializers.CharField()
    content = serializers.CharField()
    publishTime = serializers.CharField()
    holdTime = serializers.CharField()
    status = serializers.CharField(source='get_status_display')
    staff_id = serializers.CharField()
    window_id = serializers.CharField()

    class Meta:
        model = S_Notice
        fields = ['id', 'title', 'content', 'publishTime', 'holdTime', 'status', 'staff_id', 'window_id']


class s_NoticeManage(ListModelMixin, GenericViewSet):
    queryset = S_Notice.objects.all()
    serializer_class = NoticeSListSerializer
